<div id="banner">
    <div class="red">
        [$result.msg]
    </div>
    <div>
    	<div id="sec_module">
    		<!--purpose widget add -->
    		<include: file="../part/purpose.html">
		</div>
    	<div id="main_module">
    		<div id="main_module_content">
		        <form action="/admin/admin_banner/savebanner" name="addbanner" id="addbanner" method="post">
		            <input type="hidden" name="banner[b_id]" value="[$banner.b_id]"/>
					<input type="hidden" name="banner[b_purpose]" id="b_purpose" value="[$banner.b_purpose]"/>
		            <table>
		                <tr>
		                    <td>
		                        请上传广告素材：
		                    </td>
		                    <td>
		                        <input class="file" type="file" name="upload_file" id="upload_file"/>
		                    </td>
							 <td>
		                        <input class="input" type="button" value="上传并保存" name="update_save" id="update_save"/>
		                    </td>
							<td id="upload_status">
							</td>
		                </tr>
		            </table>
		        </form>
		        <form action="/admin/admin_banner/savebanner" name="savebanner" id="savebanner" method="post">
		        </form>
		 </div>
    </div>
</div>
<script>
    $(function(){
        $("#update_save").click(function(){
			var $this = $(this);
			var $val  = $("#upload_file").val();
			var $radio = $("[name=b_purpose]:checked");
			
			if($val=="")
			{
				$.showPageInfo("#page_info", "请选择文件", 500, true);
				return false;				
			}
			if($radio.size()==0)
			{
				$.showPageInfo("#page_info", "请选择存放目录", 500, true);
				return false;
			}
			$("#upload_status").html("<div class='busying'></div>");
            $("#addbanner").ajaxSubmit({
                dataType: 'html',
				data:{b_purpose:$radio.attr("title")},
                success: function(data){
                    $("#savebanner").html(data);
					$("#upload_status .busying").fadeOut(400);
                }
            });
            return false;
        });
        $(":submit").live('click', function(e){
            $.ajaxSubmit($(this).parents('form'), function(data){
                $.showPageInfo("#page_info", data.info, 500, true);
            });
            return false;
        });
    });
</script>
